import { request } from '@/service/request';
import type { PostSearchParams, PostVO, System } from '@/service/types/system';

export function getPageList(params?: PostSearchParams) {
  return request<System.PostVo>({
    url: '/system/post/list',
    method: 'get',
    params
  });
}

export function getPostSelect(deptId?: string | number) {
  const prefixUrl = deptId ? `?deptId=${deptId}` : '';
  return request<System.PostVo[]>({
    url: `system/post/optionselect${prefixUrl}`,
    method: 'get'
  });
}

export function addPost(data: PostVO) {
  return request({
    url: '/system/post',
    method: 'POST',
    data
  });
}
export function editPost(data: PostVO) {
  return request({
    url: '/system/post',
    method: 'PUT',
    data
  });
}

export function delPost(id: number | number[]) {
  return request({
    url: `/system/post/${id}`,
    method: 'DELETE'
  });
}

export function getPost(id: number) {
  return request({
    url: `/system/post/${id}`,
    method: 'GET'
  });
}
